/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projet_maths_svn;

/**
 *
 * @author JR
 */
public class Token {
    int number;
    double chance;
    double chanceLucky;
    double chancePoisson;
    double chanceLuckyPoisson;
    
    public Token(int aNum, double aDouble)
    {
        number = aNum;
        chance = aDouble;
        chanceLucky = aDouble;
        chancePoisson = aDouble;
        chanceLuckyPoisson = aDouble;
    }
    
    public Token(int aNum)
    {
        number = aNum;
        Refresh();
    }
    
    public void Refresh()
    {
        chance = Engine.ChancesOfAInNextGame(number);
        chanceLucky = Engine.ChancesOfALuckyInNextGame(number);    
        chancePoisson = Engine.ChancesOfAInNextGamePoisson(number);
        chanceLuckyPoisson = Engine.ChancesOfALuckyInNextGamePoisson(number);
    }
    
    public void Draw()
    {
        String tmp = "";
        tmp += "[" + String.format("%02d",number) + "]";
        System.out.println(tmp);
    }
    
    public String ToStringChance()
    {
        String tmp = "";
        //tmp += "[" + aList.toArray()[i].toString() + "]";
        tmp += "["
                + String.format("%02d",number)
                + "][CB:"
                + String.format("%.10f",chance)
                + "][CP:"
                + String.format("%.10f",chancePoisson)
                + "]/RP:"
                + String.format("%.10f",chance / chancePoisson)
                + "\\";      
        //System.out.println(tmp);
        return tmp;
    }
    
    public String ToStringLucky()
    {
        
        String tmp = "";
        //tmp += "[" + aList.toArray()[i].toString() + "]";
        tmp += "*"
                + String.format("%02d",number)
                + "**LB:"
                + String.format("%.10f",chanceLucky)
                + "**LP:"
                + String.format("%.10f",chanceLuckyPoisson)
                + "*/RP:"
                + String.format("%.10f",chanceLucky / chanceLuckyPoisson)
                + "\\";
        //System.out.println(tmp);
        return tmp;
    }
    
    public String ToStringAll()
    {
        String tmp = "[(" + String.format("%02d",Engine.GetOccurences(number)) + "/" + String.format("%02d",Engine.GetOccurencesOfLucky(number)) +")"
            + String.format("%02d",number)
            + "][CB:"
            + String.format("%.10f",chance)
            + "][CP:"
            + String.format("%.10f",chancePoisson)
            + "]/RP:"
            + String.format("%.10f",chance / chancePoisson)
            + "\\*LB:"
            + String.format("%.10f",chanceLucky)
            + "**LP:"
            + String.format("%.10f",chanceLuckyPoisson)
            + "*/RP:"
            + String.format("%.10f",chanceLucky / chanceLuckyPoisson)
            + "\\";
        return tmp;
    }
    
    public boolean equals(Token t)
    {
        return t.number == number;
    }
    
    public boolean equals(int i)
    {
        //System.out.println("Compare " + i + "-" + number );
        if (i == number)
        {
            //System.out.println( i + " is eq to " + number);
        }
        return i == number;
    }
}
